package com.cyf.mq.producer;

import com.cyf.mq.constant.MqConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

/**
 * @author chenyifan
 * @create 2025-02-18 17:23
 */
@Slf4j
public class TagProducer {

    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer(MqConstant.MESSAGE_PRODUCER_GROUP_A);
        producer.setNamesrvAddr(MqConstant.NAME_SERVER_ADDR);
        producer.start();

        Message message1 = new Message(MqConstant.MESSAGE_TOPIC_King, "vip1", "vip1文章".getBytes());
        Message message2 = new Message(MqConstant.MESSAGE_TOPIC_King, "vip2", "vip2文章".getBytes());
        Message message3 = new Message(MqConstant.MESSAGE_TOPIC_King, "vip3", "vip3文章".getBytes());

        log.info("发送成功：{}", producer.send(message1));
        log.info("发送成功：{}", producer.send(message2));
        log.info("发送成功：{}", producer.send(message3));
        producer.shutdown();
    }
}
